//
// Created by leisurexi on 12/5/20.
// time_handler.c
//
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>

#define BUF_SIZE 30

void sigint(int sig) {
    char msg[BUF_SIZE];
    if (sig == SIGINT) {
        puts("Are you sure exit the program?");
        fgets(msg, sizeof(msg), stdin);
        if (!strcmp(msg, "Y\n") || !strcmp(msg, "y\n")) {
            _exit(0);
        }
    }
}

int main(int argc, char *argv[]) {
    struct sigaction act;
    act.sa_handler = sigint;
    sigemptyset(&act.sa_mask);
    act.sa_flags = 0;
    sigaction(SIGINT, &act, 0);

    while (1) {
        printf("leisurexi\n");
        sleep(1);
    }

}